using System;

using Microsoft.Cci;
using Microsoft.FxCop.Sdk.Introspection;

namespace Tyng.Rules
{
	public abstract class MethodRuleBase<T> : RuleBase<T>
        where T : MethodRuleBase<T>
	{
		protected MethodRuleBase() {}
		
		public sealed override ProblemCollection Check(Member member)
		{
			Method method = member as Method;

			if(method == null || ! ShouldCheckMethod(method))
				return null;

			return Check(method);
		}

		protected virtual bool ShouldCheckMethod(Method method)
		{
			if(method.Instructions != null && method.Instructions.Length > 0)
				return true;

			return false;
		}

		protected abstract ProblemCollection Check(Method method);
	}
}
